package com.one.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.one.annotation.RequestPermission;
import com.one.bean.Orders;
import com.one.bean.Ticket;
import com.one.bean.User;
import com.one.bean.UserTicket;
import com.one.mapper.OrderMapper;
import com.one.mapper.TicketMapper;
import com.one.mapper.UserTicketMapper;
import com.one.service.TicketService;
import com.one.util.RedisUtils;
import com.one.vo.UserVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
  * @author : zzh
  * @date : 2022/1/17
  * @return :
  * @description : 优惠券接口实现类
 */
@Service
@Slf4j
public class TicketServiceImpl implements TicketService {

    @Autowired
    private TicketMapper ticketMapper;

    @Autowired
    private UserTicketMapper userTicketMapper;

    @Autowired
    private OrderMapper orderMapper;

    @Autowired
    private RedisUtils redisUtils;


    /**
      * @author : zzh
      * @date : 2022/1/17
      * @return :
      * @description : 查询所有优惠券
     */
    @Override
    public List<Ticket> selectTicket() {
        LambdaQueryWrapper<Ticket> ticketLambdaQueryWrapper = new LambdaQueryWrapper<>();
        return ticketMapper.selectList(ticketLambdaQueryWrapper);
    }


    @Override
    public Ticket ticketById(Integer ticketId) {
        return ticketMapper.selectById(ticketId);
    }

    @Override
    public Boolean addUserTicket(UserTicket userTicket) {
        return userTicketMapper.insert(userTicket)>0;
    }

    @Override
    public Boolean conversion(Integer ticketId,HttpServletRequest request,UserVo userVo) {
        return true;
    }

}
